/**
 * User路由模块
 * routes\users.js
 */
 
var express = require('express');
var router = express.Router();

const user = require("../controller/user")
const auth = require("../controller/auth")
 
router.post("/register",user.register);

router.post("/login",user.login);

router.get("/logout",auth.isLogin,user.logout);

router.get("/count",auth.isLogin,auth.isAdmin,user.getCount);

router.get("/search",auth.isLogin,auth.isAdmin,user.search);

router.patch("/change-info", auth.isLogin, user.changeInfo);

router.patch("/change-password", auth.isLogin, user.changePassword);

router.patch("/reset-password/:id", auth.isLogin,auth.isAdmin, user.resetPassword);

router.get("/:id",auth.isLogin,auth.isSelfOfAdmin,user.find);

router.get("/",auth.isLogin,auth.isAdmin,user.findAll);

router.post("/",auth.isLogin,auth.isAdmin,user.add);

router.put("/:id",auth.isLogin,auth.isAdmin,user.update);

router.delete("/:id",auth.isLogin,auth.isAdmin,user.remove);

router.post("/check-password", auth.isLogin, user.checkPassword);

module.exports = router;